<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"
	contentType="text/html; charset=UTF-8"%>
<%@ include file="/v1/h5/pages/public/head.jsp"%>

<!-- 添加收货地址 -->
<div id="ldhNewAdress">
	<!-- 接受参数 -->
	<input type="hidden" id="provinceId" value="${param.provinceId}" />
	<input type="hidden" id="cityId" value="${param.cityId}" />
	<input type="hidden" id="regionId" value="${param.regionId}" />
	<input type="hidden" id="fromPage" value="${param.fromPage}" />
	<div data-role="header" class="header_fixed">
    	<a data-role="none" data-rel="back" class="back_btn">返回</a>
    	<h1>添加收货地址</h1>
    </div>
    <div data-role="content">
    	<div class="new_address">
        	<ul>
            	<li class="li_input clearfix"><label>联系人</label><input type="text" data-role="none" placeholder="联系人姓名" name="shipName" /></li>
                <li class="li_input clearfix"><label>手机号码</label><input type="text" data-role="none" placeholder="联系人手机" name="ship_mobile"/></li>
                <li class="li_click clearfix"><label>所在区域</label><span onclick="jumpProvinceList()">请选择所在区域</span></li>
                <li class="li_input clearfix"><label>收货地址</label><input type="text" data-role="none" placeholder="请输入收货地址" name="ship_address"/></li>
            </ul>
            
        </div>
         <div class="setting_address"><input type="checkbox" name="def" data-role="none" checked="checked"><span>设为默认地址</span></div>
        <div class="login_btn" style="margin:10px 10px;"><button type="button" data-role="none" onClick="$ldh_user.saveAddress(0)">保存</button></div>
        <div class="new_adress_tip">
        	<span>地址请尽量详细，如xx大楼xx室</span>
        </div>
    </div>
    <script type="text/javascript">
	    seajs.use([ctx+'/v1/h5/js/custom/ucenter/module-ucenter.js?'+Date.parse(new Date())],function(m){
			m.init(m);
			if($("#provinceId").val()!="" && $("#cityId").val()!=""  && $("#regionId").val()!=""){
				$("#ldhNewAdress input[name=ship_mobile]").val($ldh_base.getCookie("ship_mobile"))
				$("#ldhNewAdress input[name=shipName]").val($ldh_base.getCookie("shipName"))
				if($ldh_base.getCookie("provinceName")!=""){
					$("#ldhNewAdress .new_address .li_click span").html($ldh_base.getCookie("provinceName")+" "+$ldh_base.getCookie("cityName")+" "+$ldh_base.getCookie("regionName"));
				}
				
				$("#ldhNewAdress input[name=ship_address]").val($ldh_base.getCookie("ship_address"))
				$ldh_base.setCookie("provinceId",$("#provinceId").val());
		 		$ldh_base.setCookie("cityId",$("#cityId").val());
		 		$ldh_base.setCookie("regionId",$("#regionId").val()); 
			}else{
				
				$ldh_base.clearCookie("addressId");
			    $ldh_base.clearCookie("ship_address");
		 		$ldh_base.clearCookie("ship_mobile");
		 		$ldh_base.clearCookie("shipName");
		 		$ldh_base.clearCookie("provinceId");
		 		$ldh_base.clearCookie("cityId");
		 		$ldh_base.clearCookie("regionId"); 
		 		$ldh_base.clearCookie("provinceName");
		 		$ldh_base.clearCookie("cityName");
		 		$ldh_base.clearCookie("regionName");
			}
		});
	 	document.title="云便利-添加收货地址";
	 	
	 	//跳转到省份列表
	 	function jumpProvinceList(){
	 		
	 		window.location.href=ctx+"/h5/provinceList.shtml";
	 		
	 	    $ldh_base.setCookie("ship_address",$("#ldhNewAdress input[name=ship_address]").val());
	 		$ldh_base.setCookie("ship_mobile",$("#ldhNewAdress input[name=ship_mobile]").val());
	 		$ldh_base.setCookie("shipName",$("#ldhNewAdress input[name=shipName]").val());
	 		//$ldh_base.setCookie("memo",$("#ldhNewAdress .new_address .li_click span").html()+" "+$("#ldhNewAdress input[name=ship_address]").val());
	 		$ldh_base.setCookie("provinceId",$("#provinceId").val());
	 		$ldh_base.setCookie("cityId",$("#cityId").val());
	 		$ldh_base.setCookie("regionId",$("#regionId").val()); 
			
	 	}
    </script>
</div>

<%@ include file="/v1/h5/pages/public/footer.jsp"%>
